   loadComment();
    var jsons = jsonData();                            
    var id   = jsons.id;                               
    var user_flag  = jsons.user_flag;                             
    var reply_uid ='';
    var reply_name ='';

    function userFlag(){
        if( user_flag == 0 ){
          $(".part_one .xxx").hide();
        }
      }
    userFlag();


    /* 删除评论功能 */
    $(document).on("touchstart",".part_one .xxx",function(){
      var remove_id = $(this).parents(".sss").attr("remove_id");
      _this = $(this);
        removeAjax(remove_id);
    });
    //   //请求Ajax
    function removeAjax(remove_id){
        var title = $("head title").html();
 
        var numTitle =title.replace(/[^0-9]/ig,"");

        var url = 'http://h5.518yin.com/h5/Topic/deleteComment';
        $.ajax({
            type: 'get',
            url: url + '?id='+remove_id,
            dataType: 'json',
            beforeSend: function() {
                // 禁用按钮防止重复提交
                $(document).off('click', _click);
            },
            success: function(data) {
                //数据传递验证成功后执行的操作
                if (data.code == 200) {
                   _this.parents(".sss").remove();
                   if(numTitle>0){
                      numTitle--;
                    }else{
                      numTitle=0;
                    }
                  $("head title").html("讨论("+numTitle+")");
                }
            },
            error:function(data){
              console.log(data)
            },
            complete: function() {
                if (flag == 1) {
                    $(document).off('click', _click);
                } else {
                    $(document).on('click', _click);
                }
            },
        });
    }


    $(document).on("click",".part_one .left",replyName1);
    $(document).on("click",".part_one #right b",replyName1);
    $(document).on("click",".part_one .right b",replyName1);
    $(document).on("click",".part_one",replyName2);

    $(document).on("click",".part_two .left",replyName1);
    $(document).on("click",".part_two #right b",replyName1);
    $(document).on("click",".part_two .right b",replyName1);
    $(document).on("click",".part_two",replyName2);

    function replyName1(event){
        var text_name=$(this).parents(".part_one").find("b").html();
        var reply_uid = $(this).parents(".part_one").attr("reply_id");
        var cid =  $("#cid").val();
        var api =  $("#api").val();
        replyUser(reply_uid,text_name,cid,api);
//        $('footer input').attr('placeholder','回复：'+text_name);
//        event.stopPropagation();//阻止冒泡
    }

    function replyName2(){
        reply_uid = "";
        
        $('footer input').attr('placeholder',"输入发表你的观点吧！...");
    }

    function loadComment(){
	var api =  $("#api").val();
	var cid =  $("#cid").val();
	var t='honglu://www.honglu.com/comment?show=1&api='+api+'&type=2&cid='+cid;
	window.location.href=t;
    }

    function replyUser(reply_uid,reply_name,cid,api){
	var t='honglu://www.honglu.com/reply?reply_uid='+reply_uid+'&name= '+reply_name+'&type=2&cid='+cid+'&api='+api;
	window.location.href=t;
    }

    // 点击发送
    $(".sent").on('click', _click = function() {

        var flag = 0;
        var feedContent = $("footer input").val();
        postAjax(flag,feedContent);
    });
    //请求Ajax
    function postAjax(flag,feedContent){
        var url = 'http://h5.518yin.com/h5/Topic/add_comment';
        $.ajax({
            type: 'get',
            url: url + '?id='+id+"&reply_uid="+reply_uid+"&content="+feedContent,
            dataType: 'json',
            beforeSend: function() {
                // 禁用按钮防止重复提交
                $(document).off('click', _click);
            },
            success: function(data) {
                //数据传递验证成功后执行的操作
                console.log(data)
                if (data.code == 200) {
                      window.location.reload();
                }
            },
            error:function(data){
            console.log(data)
            },
            complete: function() {
                if (flag == 1) {
                    $(document).off('click', _click);
                } else {
                    $(document).on('click', _click);
                }
            },
        });
     }

    var page = 1;
    var ready = true;
    $(document).on('scroll', _scroll = function() {
        var flag = 0; //是否加载到最后一页
        //滚动触发ajax条件
        if (checkscrollside()) {
          page++;
        //  alert(page)
          scrollAjax(page,flag);
        };
    });

    //滚动条件
    function checkscrollside() {
      return ($(document).scrollTop() == $(document).height() - $(window).height()) ? true : false;
    }
    //滚动请求Ajax
    function scrollAjax(page,flag){
            var url1 ='http://h5.518yin.com/h5/Topic/comment';
            $.ajax({
                type: 'get',
                url:  url1 + '?page=' + page+"&id="+id,
                dataType: 'json',
                timeout: 6000,
                beforeSend: function() {
                    // 禁用按钮防止重复提交
                    $(document).off('scroll', _scroll);
                },
                success: function(data) {
                    console.log(data);
                    //数据传递验证成功后执行的操作
                   if (data.code == 200) {
                      for(var i = 0; i < data.result.list.length; i++) {
                            //alert(data.result[i].reply_id);
                            if( data.result.list[i].reply_id ==null || data.result.list[i].reply_id ==''){
                                 var str1 ='';
                                if(data.result.list[i].level){
                                    str1 = "<div class='part_one sss' reply_id="+data.result.list[i].uid+" remove_id="+data.result.list[i].id+"><div class='xxx'><img src='http://static5.518yin.com/mobile/images/topic/xxx.png'></div><div class='left' style='border-radius: 50%;' > <img src="+data.result.list[i].header_img+"></div><div class='right'  ><b>"+data.result.list[i].user_name+"</b><h5 id='name1' style='color:white;margin: 0;font-size: 0.2rem' >"+data.result.list[i].level+"</h5><span id='timer' >"+data.result.list[i].announce_time+"</span><p style='margin-top: 0.8rem;font-size: 0.3rem' >"+data.result.list[i].content+"</p></div></div>";
                                }else{
                                     str1 = "<div class='part_one sss' reply_id="+data.result.list[i].uid+" remove_id="+data.result.list[i].id+"><div class='xxx'><img src='http://static5.518yin.com/mobile/images/topic/xxx.png'></div><div class='left' style='border-radius: 50%;' > <img src="+data.result.list[i].header_img+" ></div><div class='right'  ><b>"+data.result.list[i].user_name+"</b><span id='timer' >"+data.result.list[i].announce_time+"</span><p style='margin-top: 0.8rem;font-size: 0.3rem' >"+data.result.list[i].content+"</p></div></div>";
                                }
                                $("section").append(str1);
                                 userFlag();

                            }else{
                                var str2 ='';
                                if(data.result.list[i].level){
                                     str2 = "<div class='part_one part_two sss' reply_id="+data.result.list[i].uid+" remove_id="+data.result.list[i].id+"><div class='xxx'><img src='http://static5.518yin.com/mobile/images/topic/xxx.png'></div><div class='left'> <img src="+data.result.list[i].header_img+"  ></div> <div id='right'><b>"+data.result.list[i].user_name+"</b><h5 id='name' style='color:white;margin: 0;font-size: 0.2rem' >"+data.result.list[i].level+"</h5><span>"+data.result.list[i].announce_time+"</span><p  style='margin-top: 0.17rem;margin-bottom: 0.25rem'>回复<a href='javascript:;' style='color:#ffbb79;font-size: 0.3rem;' >"+data.result.list[i].reply_user_name+"</a>"+data.result.list[i].content+"</p></div></div>";
                                }else{
                                     str2 = "<div class='part_one part_two sss' reply_id="+data.result.list[i].uid+" remove_id="+data.result.list[i].id+"><div class='xxx'><img src='http://static5.518yin.com/mobile/images/topic/xxx.png'></div><div class='left'> <img src="+data.result.list[i].header_img+"  ></div> <div id='right'><b>"+data.result.list[i].user_name+"</b><span>"+data.result.list[i].announce_time+"</span><p  style='margin-top: 0.17rem;margin-bottom: 0.25rem'>回复<a href='javascript:;' style='color:#ffbb79;font-size: 0.3rem;' >"+data.result.list[i].reply_user_name+"</a>"+data.result.list[i].content+"</p></div></div>";
                                }
                                $("section").append(str2);
                                 userFlag();
                            }
                        }
                        if(data.result.list == ""){
                                 flag = 1
                                  $('body').append('<div class="noData" style="font-size:0.25rem">没有更多数据了</div>');
                               setTimeout(function(){
                                    $(".noData").hide();
                               },2000)

                         }
                    }
                },
                complete: function() {
                    //    /*没有数据,解除滚动事件*!/
                    if (flag == 1) {
                        $(document).off('scroll', _scroll);
                    } else {
                        $(document).on('scroll', _scroll);
                    }
                },
            })
    }